﻿
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_CM_GetClientsByStaff_V2]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_CM_GetClientsByStaff_V2];
GO
CREATE PROCEDURE [dbo].[sproc_CM_GetClientsByStaff_V2]
    @staffid int
AS
BEGIN
SET NOCOUNT ON

SELECT
        UDS_CM_ClientInfo.*,
        convert(nvarchar(10),UDS_CM_ClientInfo.UpdateTime,120) as updatetime1,
        UDS_CM_Linkman.Name AS Linkman
    FROM
        dbo.UDS_CM_ClientInfo LEFT JOIN dbo.UDS_CM_Linkman ON UDS_CM_Linkman.ID=ChiefLinkmanID
    WHERE
        AddManID = @staffid 
    ORDER BY
        UpdateTime DESC;
END
GO
